package com.wyx.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.groups.Default;
import lombok.Data;

import java.time.LocalDateTime;

@Data
public class Category {
    @NotNull(groups = Update.class) // 更新时必须
    private Integer id;
    @NotEmpty(groups = {Add.class, Update.class}) //对添加和更新时必须非空
    private String name;
    @NotEmpty/*(groups = {Add.class, Update.class})*/ //默认非空
    private String alias;
    private Integer createUser;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;
    public interface Add extends Default {} // 通过继承Default使alias默认不能为空
    public interface Update extends Default{}
}
